﻿using Mojito.Data.Enums;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Linq;
using System.Net;

namespace Mojito.Model
{
    public class HeaderDto
    {
        public string Key { get; set; }
        public string Value { get; set; }
    }

    public class RequestDto
    {
        public string Id { get; set; }
        public string Title { get; set; }
        public short Status { get; set; }
        public string Description { get; set; }
        public string Url { get; set; }
        public RequestMethod Method { get; set; }
        public string HeaderString { get => JsonConvert.SerializeObject(Header); }
        public IList<HeaderDto> Header { get; set; }
        public string Body { get; set; }
        public string FolderId { get; set; }
        public string ExampleId { get; set; }
        public Example RequestExample { get; set; }
        public Example ResponseExample { get; set; }

        public IList<HeaderDto> SetHeader(string header)
        {
            Header = JsonConvert.DeserializeObject<List<HeaderDto>>(header);
            return Header;
        }

        public class Example
        {
            public string Text { get; set; }
            public object Json { get; set; }
        }
    }

    public class DoRequestInput
    {
        public string Url { get; set; }
        public RequestMethod Method { get; set; }
        public IList<HeaderDto> Header { get; set; }
        public string Body { get; set; }
        public string EnviromentId { get; set; }
    }

    public class DoRequestOutput
    {
        public HttpStatusCode StatusCode { get; set; }
        public string StatusText { get; set; }
        public IList<HeaderDto> Header { get; set; }
        public string Body { get; set; }
    }
}
